﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PefStudio.Windows;
using System.ComponentModel.Composition;
using System.Windows.Forms;

namespace PefStudio.SegyViewer
{
    [Export(MainToolsMenus.Contract, typeof(IMenuItem))]
    sealed class OpenSegyViewer : AbstractMenuItem
    {
        public OpenSegyViewer()
        {
            this.ID = "SegyViewer";
            this.Text = "Segy Viewer";
        }

        //[Import(MainToolsMenus.Contract, typeof(SegyViewerDocument))]
        //private ExportFactory<SegyViewerDocument> DocumentFactory { get; set; }

        protected override void OnClick(EventArgs e)
        {
            using (var openFileDialog = new OpenFileDialog())
            {
                openFileDialog.AddExtension = true;
                //openFileDialog.Filter = SegyViewerSetting.GetAllSegysFilter();
                openFileDialog.Multiselect = false;
                openFileDialog.CheckFileExists = true;
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    var doc =
                        MainWindow.CompositionContainer.GetExportedValue<SegyViewerDocument>(SegyViewerDocument.Contract);
                    doc.CurrentSegyFile = openFileDialog.FileName;
                    MainWindow.ShowFloatDocument(doc);
                }
            }
        }
    }
}
